using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace LiteNetLib.Utils
{
	public sealed class NetSerializer
	{
		private sealed class NestedType
		{
			public readonly NestedTypeWriter WriteDelegate;

			public readonly NestedTypeReader ReadDelegate;

			public NestedType(NestedTypeWriter writeDelegate, NestedTypeReader readDelegate)
			{
				WriteDelegate = writeDelegate;
				ReadDelegate = readDelegate;
			}
		}

		private delegate void NestedTypeWriter(NetDataWriter writer, object customObj);

		private delegate object NestedTypeReader(NetDataReader reader);

		private sealed class StructInfo
		{
			public readonly Action<NetDataWriter>[] WriteDelegate;

			public readonly Action<NetDataReader>[] ReadDelegate;

			public object Reference;

			private readonly int _membersCount;

			public StructInfo(int membersCount)
			{
				_membersCount = membersCount;
				WriteDelegate = new Action<NetDataWriter>[membersCount];
				ReadDelegate = new Action<NetDataReader>[membersCount];
			}

			public void Write(NetDataWriter writer, object obj)
			{
				Reference = obj;
				for (int i = 0; i < _membersCount; i++)
				{
					WriteDelegate[i](writer);
				}
			}

			public void Read(NetDataReader reader)
			{
				for (int i = 0; i < _membersCount; i++)
				{
					ReadDelegate[i](reader);
				}
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass11_0<T> where T : INetSerializable
		{
			public Func<T> constructor;

			internal object _003CRegisterNestedTypeInternal_003Eb__1(NetDataReader reader)
			{
				T val = constructor();
				val.Deserialize(reader);
				return val;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class _003C_003Ec__11<T> where T : INetSerializable
		{
			public static readonly _003C_003Ec__11<T> _003C_003E9 = new _003C_003Ec__11<T>();

			public static NestedTypeWriter _003C_003E9__11_0;

			internal void _003CRegisterNestedTypeInternal_003Eb__11_0(NetDataWriter writer, object obj)
			{
				((T)obj/*cast due to .constrained prefix*/).Serialize(writer);
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class _003C_003Ec__12<T> where T : struct, INetSerializable
		{
			public static readonly _003C_003Ec__12<T> _003C_003E9 = new _003C_003Ec__12<T>();

			public static Func<T> _003C_003E9__12_0;

			internal T _003CRegisterNestedType_003Eb__12_0()
			{
				return new T();
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass14_0<T>
		{
			public Action<NetDataWriter, T> writeDelegate;

			public Func<NetDataReader, T> readDelegate;

			internal void _003CRegisterNestedType_003Eb__0(NetDataWriter writer, object obj)
			{
				writeDelegate(writer, (T)obj);
			}

			internal object _003CRegisterNestedType_003Eb__1(NetDataReader reader)
			{
				return readDelegate(reader);
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_0<T>
		{
			public StructInfo info;

			public NetSerializer _003C_003E4__this;
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_1<T>
		{
			public PropertyInfo property;

			public Type propertyType;

			public _003C_003Ec__DisplayClass18_0<T> CS_0024_003C_003E8__locals1;

			internal void _003CRegisterInternal_003Eb__0(NetDataReader reader)
			{
				property.SetValue(CS_0024_003C_003E8__locals1.info.Reference, Enum.ToObject(propertyType, reader.GetByte()), null);
			}

			internal void _003CRegisterInternal_003Eb__1(NetDataWriter writer)
			{
				writer.Put((byte)property.GetValue(CS_0024_003C_003E8__locals1.info.Reference, null));
			}

			internal void _003CRegisterInternal_003Eb__2(NetDataReader reader)
			{
				property.SetValue(CS_0024_003C_003E8__locals1.info.Reference, Enum.ToObject(propertyType, reader.GetInt()), null);
			}

			internal void _003CRegisterInternal_003Eb__3(NetDataWriter writer)
			{
				writer.Put((int)property.GetValue(CS_0024_003C_003E8__locals1.info.Reference, null));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_2<T>
		{
			public Action<T, string> setDelegate;

			public Func<T, string> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals2;

			internal void _003CRegisterInternal_003Eb__4(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.Reference, reader.GetString());
			}

			internal void _003CRegisterInternal_003Eb__5(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.Reference));
			}

			internal void _003CRegisterInternal_003Eb__6(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.Reference, reader.GetString(CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1._003C_003E4__this._maxStringLength));
			}

			internal void _003CRegisterInternal_003Eb__7(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.Reference), CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1._003C_003E4__this._maxStringLength);
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_3<T>
		{
			public Action<T, bool> setDelegate;

			public Func<T, bool> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals3;

			internal void _003CRegisterInternal_003Eb__8(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals3.CS_0024_003C_003E8__locals1.info.Reference, reader.GetBool());
			}

			internal void _003CRegisterInternal_003Eb__9(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals3.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_4<T>
		{
			public Action<T, byte> setDelegate;

			public Func<T, byte> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals4;

			internal void _003CRegisterInternal_003Eb__10(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals4.CS_0024_003C_003E8__locals1.info.Reference, reader.GetByte());
			}

			internal void _003CRegisterInternal_003Eb__11(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals4.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_5<T>
		{
			public Action<T, sbyte> setDelegate;

			public Func<T, sbyte> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals5;

			internal void _003CRegisterInternal_003Eb__12(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals5.CS_0024_003C_003E8__locals1.info.Reference, reader.GetSByte());
			}

			internal void _003CRegisterInternal_003Eb__13(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals5.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_6<T>
		{
			public Action<T, short> setDelegate;

			public Func<T, short> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals6;

			internal void _003CRegisterInternal_003Eb__14(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals6.CS_0024_003C_003E8__locals1.info.Reference, reader.GetShort());
			}

			internal void _003CRegisterInternal_003Eb__15(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals6.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_7<T>
		{
			public Action<T, ushort> setDelegate;

			public Func<T, ushort> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals7;

			internal void _003CRegisterInternal_003Eb__16(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals7.CS_0024_003C_003E8__locals1.info.Reference, reader.GetUShort());
			}

			internal void _003CRegisterInternal_003Eb__17(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals7.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_8<T>
		{
			public Action<T, int> setDelegate;

			public Func<T, int> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals8;

			internal void _003CRegisterInternal_003Eb__18(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals8.CS_0024_003C_003E8__locals1.info.Reference, reader.GetInt());
			}

			internal void _003CRegisterInternal_003Eb__19(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals8.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_9<T>
		{
			public Action<T, uint> setDelegate;

			public Func<T, uint> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals9;

			internal void _003CRegisterInternal_003Eb__20(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals9.CS_0024_003C_003E8__locals1.info.Reference, reader.GetUInt());
			}

			internal void _003CRegisterInternal_003Eb__21(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals9.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_10<T>
		{
			public Action<T, long> setDelegate;

			public Func<T, long> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals10;

			internal void _003CRegisterInternal_003Eb__22(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals10.CS_0024_003C_003E8__locals1.info.Reference, reader.GetLong());
			}

			internal void _003CRegisterInternal_003Eb__23(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals10.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_11<T>
		{
			public Action<T, ulong> setDelegate;

			public Func<T, ulong> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals11;

			internal void _003CRegisterInternal_003Eb__24(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals11.CS_0024_003C_003E8__locals1.info.Reference, reader.GetULong());
			}

			internal void _003CRegisterInternal_003Eb__25(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals11.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_12<T>
		{
			public Action<T, float> setDelegate;

			public Func<T, float> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals12;

			internal void _003CRegisterInternal_003Eb__26(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals12.CS_0024_003C_003E8__locals1.info.Reference, reader.GetFloat());
			}

			internal void _003CRegisterInternal_003Eb__27(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals12.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_13<T>
		{
			public Action<T, double> setDelegate;

			public Func<T, double> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals13;

			internal void _003CRegisterInternal_003Eb__28(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals13.CS_0024_003C_003E8__locals1.info.Reference, reader.GetDouble());
			}

			internal void _003CRegisterInternal_003Eb__29(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals13.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_14<T>
		{
			public Action<T, char> setDelegate;

			public Func<T, char> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals14;

			internal void _003CRegisterInternal_003Eb__30(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals14.CS_0024_003C_003E8__locals1.info.Reference, reader.GetChar());
			}

			internal void _003CRegisterInternal_003Eb__31(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals14.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_15<T>
		{
			public Action<T, IPEndPoint> setDelegate;

			public Func<T, IPEndPoint> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals15;

			internal void _003CRegisterInternal_003Eb__32(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals15.CS_0024_003C_003E8__locals1.info.Reference, reader.GetNetEndPoint());
			}

			internal void _003CRegisterInternal_003Eb__33(NetDataWriter writer)
			{
				writer.Put(getDelegate((T)CS_0024_003C_003E8__locals15.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_16<T>
		{
			public Action<T, string[]> setDelegate;

			public Func<T, string[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals16;

			internal void _003CRegisterInternal_003Eb__34(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.Reference, reader.GetStringArray());
			}

			internal void _003CRegisterInternal_003Eb__35(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.Reference));
			}

			internal void _003CRegisterInternal_003Eb__36(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.Reference, reader.GetStringArray(CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1._003C_003E4__this._maxStringLength));
			}

			internal void _003CRegisterInternal_003Eb__37(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.Reference), CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1._003C_003E4__this._maxStringLength);
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_17<T>
		{
			public Action<T, bool[]> setDelegate;

			public Func<T, bool[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals17;

			internal void _003CRegisterInternal_003Eb__38(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals17.CS_0024_003C_003E8__locals1.info.Reference, reader.GetBoolArray());
			}

			internal void _003CRegisterInternal_003Eb__39(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals17.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_18<T>
		{
			public Action<T, byte[]> setDelegate;

			public Func<T, byte[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals18;

			internal void _003CRegisterInternal_003Eb__40(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals18.CS_0024_003C_003E8__locals1.info.Reference, reader.GetBytesWithLength());
			}

			internal void _003CRegisterInternal_003Eb__41(NetDataWriter writer)
			{
				writer.PutBytesWithLength(getDelegate((T)CS_0024_003C_003E8__locals18.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_19<T>
		{
			public Action<T, short[]> setDelegate;

			public Func<T, short[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals19;

			internal void _003CRegisterInternal_003Eb__42(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals19.CS_0024_003C_003E8__locals1.info.Reference, reader.GetShortArray());
			}

			internal void _003CRegisterInternal_003Eb__43(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals19.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_20<T>
		{
			public Action<T, ushort[]> setDelegate;

			public Func<T, ushort[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals20;

			internal void _003CRegisterInternal_003Eb__44(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals20.CS_0024_003C_003E8__locals1.info.Reference, reader.GetUShortArray());
			}

			internal void _003CRegisterInternal_003Eb__45(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals20.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_21<T>
		{
			public Action<T, int[]> setDelegate;

			public Func<T, int[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals21;

			internal void _003CRegisterInternal_003Eb__46(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals21.CS_0024_003C_003E8__locals1.info.Reference, reader.GetIntArray());
			}

			internal void _003CRegisterInternal_003Eb__47(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals21.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_22<T>
		{
			public Action<T, uint[]> setDelegate;

			public Func<T, uint[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals22;

			internal void _003CRegisterInternal_003Eb__48(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals22.CS_0024_003C_003E8__locals1.info.Reference, reader.GetUIntArray());
			}

			internal void _003CRegisterInternal_003Eb__49(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals22.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_23<T>
		{
			public Action<T, long[]> setDelegate;

			public Func<T, long[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals23;

			internal void _003CRegisterInternal_003Eb__50(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals23.CS_0024_003C_003E8__locals1.info.Reference, reader.GetLongArray());
			}

			internal void _003CRegisterInternal_003Eb__51(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals23.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_24<T>
		{
			public Action<T, ulong[]> setDelegate;

			public Func<T, ulong[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals24;

			internal void _003CRegisterInternal_003Eb__52(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals24.CS_0024_003C_003E8__locals1.info.Reference, reader.GetULongArray());
			}

			internal void _003CRegisterInternal_003Eb__53(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals24.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_25<T>
		{
			public Action<T, float[]> setDelegate;

			public Func<T, float[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals25;

			internal void _003CRegisterInternal_003Eb__54(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals25.CS_0024_003C_003E8__locals1.info.Reference, reader.GetFloatArray());
			}

			internal void _003CRegisterInternal_003Eb__55(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals25.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_26<T>
		{
			public Action<T, double[]> setDelegate;

			public Func<T, double[]> getDelegate;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals26;

			internal void _003CRegisterInternal_003Eb__56(NetDataReader reader)
			{
				setDelegate((T)CS_0024_003C_003E8__locals26.CS_0024_003C_003E8__locals1.info.Reference, reader.GetDoubleArray());
			}

			internal void _003CRegisterInternal_003Eb__57(NetDataWriter writer)
			{
				writer.PutArray(getDelegate((T)CS_0024_003C_003E8__locals26.CS_0024_003C_003E8__locals1.info.Reference));
			}
		}

		[CompilerGenerated]
		private sealed class _003C_003Ec__DisplayClass18_27<T>
		{
			public NestedType registeredNestedType;

			public _003C_003Ec__DisplayClass18_1<T> CS_0024_003C_003E8__locals27;

			internal void _003CRegisterInternal_003Eb__58(NetDataReader reader)
			{
				ushort uShort = reader.GetUShort();
				Array array = Array.CreateInstance(CS_0024_003C_003E8__locals27.propertyType, uShort);
				for (int i = 0; i < uShort; i++)
				{
					array.SetValue(registeredNestedType.ReadDelegate(reader), i);
				}
				CS_0024_003C_003E8__locals27.property.SetValue(CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.Reference, array, null);
			}

			internal void _003CRegisterInternal_003Eb__59(NetDataWriter writer)
			{
				Array array = (Array)CS_0024_003C_003E8__locals27.property.GetValue(CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.Reference, null);
				writer.Put((ushort)array.Length);
				for (int i = 0; i < array.Length; i++)
				{
					registeredNestedType.WriteDelegate(writer, array.GetValue(i));
				}
			}

			internal void _003CRegisterInternal_003Eb__60(NetDataReader reader)
			{
				CS_0024_003C_003E8__locals27.property.SetValue(CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.Reference, registeredNestedType.ReadDelegate(reader), null);
			}

			internal void _003CRegisterInternal_003Eb__61(NetDataWriter writer)
			{
				registeredNestedType.WriteDelegate(writer, CS_0024_003C_003E8__locals27.property.GetValue(CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.Reference, null));
			}
		}

		private static readonly HashSet<Type> BasicTypes;

		private readonly NetDataWriter _writer;

		private readonly int _maxStringLength;

		private readonly Dictionary<string, StructInfo> _registeredTypes;

		private readonly Dictionary<Type, NestedType> _registeredNestedTypes;

		public NetSerializer()
			: this(0)
		{
		}

		public NetSerializer(int maxStringLength)
		{
			_maxStringLength = maxStringLength;
			_registeredTypes = new Dictionary<string, StructInfo>();
			_registeredNestedTypes = new Dictionary<Type, NestedType>();
			_writer = new NetDataWriter();
		}

		private bool RegisterNestedTypeInternal<T>(Func<T> constructor) where T : INetSerializable
		{
			_003C_003Ec__DisplayClass11_0<T> _003C_003Ec__DisplayClass11_ = new _003C_003Ec__DisplayClass11_0<T>();
			_003C_003Ec__DisplayClass11_.constructor = constructor;
			Type typeFromHandle = typeof(T);
			if (_registeredNestedTypes.ContainsKey(typeFromHandle))
			{
				return false;
			}
			NestedType value = new NestedType(_003C_003Ec__11<T>._003C_003E9__11_0 ?? (_003C_003Ec__11<T>._003C_003E9__11_0 = new NestedTypeWriter(_003C_003Ec__11<T>._003C_003E9._003CRegisterNestedTypeInternal_003Eb__11_0)), new NestedTypeReader(_003C_003Ec__DisplayClass11_._003CRegisterNestedTypeInternal_003Eb__1));
			_registeredNestedTypes.Add(typeFromHandle, value);
			return true;
		}

		public bool RegisterNestedType<T>() where T : struct, INetSerializable
		{
			return RegisterNestedTypeInternal(_003C_003Ec__12<T>._003C_003E9__12_0 ?? (_003C_003Ec__12<T>._003C_003E9__12_0 = new Func<T>(_003C_003Ec__12<T>._003C_003E9._003CRegisterNestedType_003Eb__12_0)));
		}

		public bool RegisterNestedType<T>(Func<T> constructor) where T : class, INetSerializable
		{
			return RegisterNestedTypeInternal(constructor);
		}

		public bool RegisterNestedType<T>(Action<NetDataWriter, T> writeDelegate, Func<NetDataReader, T> readDelegate)
		{
			_003C_003Ec__DisplayClass14_0<T> _003C_003Ec__DisplayClass14_ = new _003C_003Ec__DisplayClass14_0<T>();
			_003C_003Ec__DisplayClass14_.writeDelegate = writeDelegate;
			_003C_003Ec__DisplayClass14_.readDelegate = readDelegate;
			Type typeFromHandle = typeof(T);
			if (BasicTypes.Contains(typeFromHandle) || _registeredNestedTypes.ContainsKey(typeFromHandle))
			{
				return false;
			}
			NestedType value = new NestedType(new NestedTypeWriter(_003C_003Ec__DisplayClass14_._003CRegisterNestedType_003Eb__0), new NestedTypeReader(_003C_003Ec__DisplayClass14_._003CRegisterNestedType_003Eb__1));
			_registeredNestedTypes.Add(typeFromHandle, value);
			return true;
		}

		private static Delegate CreateDelegate(Type type, MethodInfo info)
		{
			return Delegate.CreateDelegate(type, info);
		}

		private static Func<TClass, TProperty> ExtractGetDelegate<TClass, TProperty>(MethodInfo info)
		{
			return (Func<TClass, TProperty>)CreateDelegate(typeof(Func<TClass, TProperty>), info);
		}

		private static Action<TClass, TProperty> ExtractSetDelegate<TClass, TProperty>(MethodInfo info)
		{
			return (Action<TClass, TProperty>)CreateDelegate(typeof(Action<TClass, TProperty>), info);
		}

		private StructInfo RegisterInternal<T>()
		{
			_003C_003Ec__DisplayClass18_0<T> _003C_003Ec__DisplayClass18_ = new _003C_003Ec__DisplayClass18_0<T>();
			_003C_003Ec__DisplayClass18_._003C_003E4__this = this;
			Type typeFromHandle = typeof(T);
			string fullName = typeFromHandle.FullName;
			if (_registeredTypes.TryGetValue(fullName, out _003C_003Ec__DisplayClass18_.info))
			{
				return _003C_003Ec__DisplayClass18_.info;
			}
			PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty);
			int num = properties.Length;
			if (properties == null)
			{
				throw new InvalidTypeException("Type does not contain acceptable fields");
			}
			_003C_003Ec__DisplayClass18_.info = new StructInfo(num);
			for (int i = 0; i < num; i++)
			{
				_003C_003Ec__DisplayClass18_1<T> _003C_003Ec__DisplayClass18_2 = new _003C_003Ec__DisplayClass18_1<T>();
				_003C_003Ec__DisplayClass18_2.CS_0024_003C_003E8__locals1 = _003C_003Ec__DisplayClass18_;
				_003C_003Ec__DisplayClass18_2.property = properties[i];
				_003C_003Ec__DisplayClass18_2.propertyType = _003C_003Ec__DisplayClass18_2.property.PropertyType;
				bool isEnum = _003C_003Ec__DisplayClass18_2.propertyType.IsEnum;
				MethodInfo getMethod = _003C_003Ec__DisplayClass18_2.property.GetGetMethod();
				MethodInfo setMethod = _003C_003Ec__DisplayClass18_2.property.GetSetMethod();
				if (isEnum)
				{
					Type underlyingType = Enum.GetUnderlyingType(_003C_003Ec__DisplayClass18_2.propertyType);
					if (underlyingType == typeof(byte))
					{
						_003C_003Ec__DisplayClass18_2.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_2._003CRegisterInternal_003Eb__0);
						_003C_003Ec__DisplayClass18_2.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_2._003CRegisterInternal_003Eb__1);
						continue;
					}
					if (underlyingType == typeof(int))
					{
						_003C_003Ec__DisplayClass18_2.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_2._003CRegisterInternal_003Eb__2);
						_003C_003Ec__DisplayClass18_2.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_2._003CRegisterInternal_003Eb__3);
						continue;
					}
					throw new InvalidTypeException("Not supported enum underlying type: " + underlyingType.Name);
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(string))
				{
					_003C_003Ec__DisplayClass18_2<T> _003C_003Ec__DisplayClass18_3 = new _003C_003Ec__DisplayClass18_2<T>();
					_003C_003Ec__DisplayClass18_3.CS_0024_003C_003E8__locals2 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_3.setDelegate = ExtractSetDelegate<T, string>(setMethod);
					_003C_003Ec__DisplayClass18_3.getDelegate = ExtractGetDelegate<T, string>(getMethod);
					if (_maxStringLength <= 0)
					{
						_003C_003Ec__DisplayClass18_3.CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_3._003CRegisterInternal_003Eb__4);
						_003C_003Ec__DisplayClass18_3.CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_3._003CRegisterInternal_003Eb__5);
					}
					else
					{
						_003C_003Ec__DisplayClass18_3.CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_3._003CRegisterInternal_003Eb__6);
						_003C_003Ec__DisplayClass18_3.CS_0024_003C_003E8__locals2.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_3._003CRegisterInternal_003Eb__7);
					}
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(bool))
				{
					_003C_003Ec__DisplayClass18_3<T> _003C_003Ec__DisplayClass18_4 = new _003C_003Ec__DisplayClass18_3<T>();
					_003C_003Ec__DisplayClass18_4.CS_0024_003C_003E8__locals3 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_4.setDelegate = ExtractSetDelegate<T, bool>(setMethod);
					_003C_003Ec__DisplayClass18_4.getDelegate = ExtractGetDelegate<T, bool>(getMethod);
					_003C_003Ec__DisplayClass18_4.CS_0024_003C_003E8__locals3.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_4._003CRegisterInternal_003Eb__8);
					_003C_003Ec__DisplayClass18_4.CS_0024_003C_003E8__locals3.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_4._003CRegisterInternal_003Eb__9);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(byte))
				{
					_003C_003Ec__DisplayClass18_4<T> _003C_003Ec__DisplayClass18_5 = new _003C_003Ec__DisplayClass18_4<T>();
					_003C_003Ec__DisplayClass18_5.CS_0024_003C_003E8__locals4 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_5.setDelegate = ExtractSetDelegate<T, byte>(setMethod);
					_003C_003Ec__DisplayClass18_5.getDelegate = ExtractGetDelegate<T, byte>(getMethod);
					_003C_003Ec__DisplayClass18_5.CS_0024_003C_003E8__locals4.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_5._003CRegisterInternal_003Eb__10);
					_003C_003Ec__DisplayClass18_5.CS_0024_003C_003E8__locals4.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_5._003CRegisterInternal_003Eb__11);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(sbyte))
				{
					_003C_003Ec__DisplayClass18_5<T> _003C_003Ec__DisplayClass18_6 = new _003C_003Ec__DisplayClass18_5<T>();
					_003C_003Ec__DisplayClass18_6.CS_0024_003C_003E8__locals5 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_6.setDelegate = ExtractSetDelegate<T, sbyte>(setMethod);
					_003C_003Ec__DisplayClass18_6.getDelegate = ExtractGetDelegate<T, sbyte>(getMethod);
					_003C_003Ec__DisplayClass18_6.CS_0024_003C_003E8__locals5.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_6._003CRegisterInternal_003Eb__12);
					_003C_003Ec__DisplayClass18_6.CS_0024_003C_003E8__locals5.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_6._003CRegisterInternal_003Eb__13);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(short))
				{
					_003C_003Ec__DisplayClass18_6<T> _003C_003Ec__DisplayClass18_7 = new _003C_003Ec__DisplayClass18_6<T>();
					_003C_003Ec__DisplayClass18_7.CS_0024_003C_003E8__locals6 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_7.setDelegate = ExtractSetDelegate<T, short>(setMethod);
					_003C_003Ec__DisplayClass18_7.getDelegate = ExtractGetDelegate<T, short>(getMethod);
					_003C_003Ec__DisplayClass18_7.CS_0024_003C_003E8__locals6.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_7._003CRegisterInternal_003Eb__14);
					_003C_003Ec__DisplayClass18_7.CS_0024_003C_003E8__locals6.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_7._003CRegisterInternal_003Eb__15);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(ushort))
				{
					_003C_003Ec__DisplayClass18_7<T> _003C_003Ec__DisplayClass18_8 = new _003C_003Ec__DisplayClass18_7<T>();
					_003C_003Ec__DisplayClass18_8.CS_0024_003C_003E8__locals7 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_8.setDelegate = ExtractSetDelegate<T, ushort>(setMethod);
					_003C_003Ec__DisplayClass18_8.getDelegate = ExtractGetDelegate<T, ushort>(getMethod);
					_003C_003Ec__DisplayClass18_8.CS_0024_003C_003E8__locals7.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_8._003CRegisterInternal_003Eb__16);
					_003C_003Ec__DisplayClass18_8.CS_0024_003C_003E8__locals7.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_8._003CRegisterInternal_003Eb__17);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(int))
				{
					_003C_003Ec__DisplayClass18_8<T> _003C_003Ec__DisplayClass18_9 = new _003C_003Ec__DisplayClass18_8<T>();
					_003C_003Ec__DisplayClass18_9.CS_0024_003C_003E8__locals8 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_9.setDelegate = ExtractSetDelegate<T, int>(setMethod);
					_003C_003Ec__DisplayClass18_9.getDelegate = ExtractGetDelegate<T, int>(getMethod);
					_003C_003Ec__DisplayClass18_9.CS_0024_003C_003E8__locals8.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_9._003CRegisterInternal_003Eb__18);
					_003C_003Ec__DisplayClass18_9.CS_0024_003C_003E8__locals8.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_9._003CRegisterInternal_003Eb__19);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(uint))
				{
					_003C_003Ec__DisplayClass18_9<T> _003C_003Ec__DisplayClass18_10 = new _003C_003Ec__DisplayClass18_9<T>();
					_003C_003Ec__DisplayClass18_10.CS_0024_003C_003E8__locals9 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_10.setDelegate = ExtractSetDelegate<T, uint>(setMethod);
					_003C_003Ec__DisplayClass18_10.getDelegate = ExtractGetDelegate<T, uint>(getMethod);
					_003C_003Ec__DisplayClass18_10.CS_0024_003C_003E8__locals9.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_10._003CRegisterInternal_003Eb__20);
					_003C_003Ec__DisplayClass18_10.CS_0024_003C_003E8__locals9.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_10._003CRegisterInternal_003Eb__21);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(long))
				{
					_003C_003Ec__DisplayClass18_10<T> _003C_003Ec__DisplayClass18_11 = new _003C_003Ec__DisplayClass18_10<T>();
					_003C_003Ec__DisplayClass18_11.CS_0024_003C_003E8__locals10 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_11.setDelegate = ExtractSetDelegate<T, long>(setMethod);
					_003C_003Ec__DisplayClass18_11.getDelegate = ExtractGetDelegate<T, long>(getMethod);
					_003C_003Ec__DisplayClass18_11.CS_0024_003C_003E8__locals10.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_11._003CRegisterInternal_003Eb__22);
					_003C_003Ec__DisplayClass18_11.CS_0024_003C_003E8__locals10.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_11._003CRegisterInternal_003Eb__23);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(ulong))
				{
					_003C_003Ec__DisplayClass18_11<T> _003C_003Ec__DisplayClass18_12 = new _003C_003Ec__DisplayClass18_11<T>();
					_003C_003Ec__DisplayClass18_12.CS_0024_003C_003E8__locals11 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_12.setDelegate = ExtractSetDelegate<T, ulong>(setMethod);
					_003C_003Ec__DisplayClass18_12.getDelegate = ExtractGetDelegate<T, ulong>(getMethod);
					_003C_003Ec__DisplayClass18_12.CS_0024_003C_003E8__locals11.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_12._003CRegisterInternal_003Eb__24);
					_003C_003Ec__DisplayClass18_12.CS_0024_003C_003E8__locals11.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_12._003CRegisterInternal_003Eb__25);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(float))
				{
					_003C_003Ec__DisplayClass18_12<T> _003C_003Ec__DisplayClass18_13 = new _003C_003Ec__DisplayClass18_12<T>();
					_003C_003Ec__DisplayClass18_13.CS_0024_003C_003E8__locals12 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_13.setDelegate = ExtractSetDelegate<T, float>(setMethod);
					_003C_003Ec__DisplayClass18_13.getDelegate = ExtractGetDelegate<T, float>(getMethod);
					_003C_003Ec__DisplayClass18_13.CS_0024_003C_003E8__locals12.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_13._003CRegisterInternal_003Eb__26);
					_003C_003Ec__DisplayClass18_13.CS_0024_003C_003E8__locals12.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_13._003CRegisterInternal_003Eb__27);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(double))
				{
					_003C_003Ec__DisplayClass18_13<T> _003C_003Ec__DisplayClass18_14 = new _003C_003Ec__DisplayClass18_13<T>();
					_003C_003Ec__DisplayClass18_14.CS_0024_003C_003E8__locals13 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_14.setDelegate = ExtractSetDelegate<T, double>(setMethod);
					_003C_003Ec__DisplayClass18_14.getDelegate = ExtractGetDelegate<T, double>(getMethod);
					_003C_003Ec__DisplayClass18_14.CS_0024_003C_003E8__locals13.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_14._003CRegisterInternal_003Eb__28);
					_003C_003Ec__DisplayClass18_14.CS_0024_003C_003E8__locals13.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_14._003CRegisterInternal_003Eb__29);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(char))
				{
					_003C_003Ec__DisplayClass18_14<T> _003C_003Ec__DisplayClass18_15 = new _003C_003Ec__DisplayClass18_14<T>();
					_003C_003Ec__DisplayClass18_15.CS_0024_003C_003E8__locals14 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_15.setDelegate = ExtractSetDelegate<T, char>(setMethod);
					_003C_003Ec__DisplayClass18_15.getDelegate = ExtractGetDelegate<T, char>(getMethod);
					_003C_003Ec__DisplayClass18_15.CS_0024_003C_003E8__locals14.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_15._003CRegisterInternal_003Eb__30);
					_003C_003Ec__DisplayClass18_15.CS_0024_003C_003E8__locals14.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_15._003CRegisterInternal_003Eb__31);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(IPEndPoint))
				{
					_003C_003Ec__DisplayClass18_15<T> _003C_003Ec__DisplayClass18_16 = new _003C_003Ec__DisplayClass18_15<T>();
					_003C_003Ec__DisplayClass18_16.CS_0024_003C_003E8__locals15 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_16.setDelegate = ExtractSetDelegate<T, IPEndPoint>(setMethod);
					_003C_003Ec__DisplayClass18_16.getDelegate = ExtractGetDelegate<T, IPEndPoint>(getMethod);
					_003C_003Ec__DisplayClass18_16.CS_0024_003C_003E8__locals15.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_16._003CRegisterInternal_003Eb__32);
					_003C_003Ec__DisplayClass18_16.CS_0024_003C_003E8__locals15.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_16._003CRegisterInternal_003Eb__33);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(string[]))
				{
					_003C_003Ec__DisplayClass18_16<T> _003C_003Ec__DisplayClass18_17 = new _003C_003Ec__DisplayClass18_16<T>();
					_003C_003Ec__DisplayClass18_17.CS_0024_003C_003E8__locals16 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_17.setDelegate = ExtractSetDelegate<T, string[]>(setMethod);
					_003C_003Ec__DisplayClass18_17.getDelegate = ExtractGetDelegate<T, string[]>(getMethod);
					if (_maxStringLength <= 0)
					{
						_003C_003Ec__DisplayClass18_17.CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_17._003CRegisterInternal_003Eb__34);
						_003C_003Ec__DisplayClass18_17.CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_17._003CRegisterInternal_003Eb__35);
					}
					else
					{
						_003C_003Ec__DisplayClass18_17.CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_17._003CRegisterInternal_003Eb__36);
						_003C_003Ec__DisplayClass18_17.CS_0024_003C_003E8__locals16.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_17._003CRegisterInternal_003Eb__37);
					}
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(bool[]))
				{
					_003C_003Ec__DisplayClass18_17<T> _003C_003Ec__DisplayClass18_18 = new _003C_003Ec__DisplayClass18_17<T>();
					_003C_003Ec__DisplayClass18_18.CS_0024_003C_003E8__locals17 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_18.setDelegate = ExtractSetDelegate<T, bool[]>(setMethod);
					_003C_003Ec__DisplayClass18_18.getDelegate = ExtractGetDelegate<T, bool[]>(getMethod);
					_003C_003Ec__DisplayClass18_18.CS_0024_003C_003E8__locals17.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_18._003CRegisterInternal_003Eb__38);
					_003C_003Ec__DisplayClass18_18.CS_0024_003C_003E8__locals17.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_18._003CRegisterInternal_003Eb__39);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(byte[]))
				{
					_003C_003Ec__DisplayClass18_18<T> _003C_003Ec__DisplayClass18_19 = new _003C_003Ec__DisplayClass18_18<T>();
					_003C_003Ec__DisplayClass18_19.CS_0024_003C_003E8__locals18 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_19.setDelegate = ExtractSetDelegate<T, byte[]>(setMethod);
					_003C_003Ec__DisplayClass18_19.getDelegate = ExtractGetDelegate<T, byte[]>(getMethod);
					_003C_003Ec__DisplayClass18_19.CS_0024_003C_003E8__locals18.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_19._003CRegisterInternal_003Eb__40);
					_003C_003Ec__DisplayClass18_19.CS_0024_003C_003E8__locals18.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_19._003CRegisterInternal_003Eb__41);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(short[]))
				{
					_003C_003Ec__DisplayClass18_19<T> _003C_003Ec__DisplayClass18_20 = new _003C_003Ec__DisplayClass18_19<T>();
					_003C_003Ec__DisplayClass18_20.CS_0024_003C_003E8__locals19 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_20.setDelegate = ExtractSetDelegate<T, short[]>(setMethod);
					_003C_003Ec__DisplayClass18_20.getDelegate = ExtractGetDelegate<T, short[]>(getMethod);
					_003C_003Ec__DisplayClass18_20.CS_0024_003C_003E8__locals19.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_20._003CRegisterInternal_003Eb__42);
					_003C_003Ec__DisplayClass18_20.CS_0024_003C_003E8__locals19.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_20._003CRegisterInternal_003Eb__43);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(ushort[]))
				{
					_003C_003Ec__DisplayClass18_20<T> _003C_003Ec__DisplayClass18_21 = new _003C_003Ec__DisplayClass18_20<T>();
					_003C_003Ec__DisplayClass18_21.CS_0024_003C_003E8__locals20 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_21.setDelegate = ExtractSetDelegate<T, ushort[]>(setMethod);
					_003C_003Ec__DisplayClass18_21.getDelegate = ExtractGetDelegate<T, ushort[]>(getMethod);
					_003C_003Ec__DisplayClass18_21.CS_0024_003C_003E8__locals20.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_21._003CRegisterInternal_003Eb__44);
					_003C_003Ec__DisplayClass18_21.CS_0024_003C_003E8__locals20.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_21._003CRegisterInternal_003Eb__45);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(int[]))
				{
					_003C_003Ec__DisplayClass18_21<T> _003C_003Ec__DisplayClass18_22 = new _003C_003Ec__DisplayClass18_21<T>();
					_003C_003Ec__DisplayClass18_22.CS_0024_003C_003E8__locals21 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_22.setDelegate = ExtractSetDelegate<T, int[]>(setMethod);
					_003C_003Ec__DisplayClass18_22.getDelegate = ExtractGetDelegate<T, int[]>(getMethod);
					_003C_003Ec__DisplayClass18_22.CS_0024_003C_003E8__locals21.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_22._003CRegisterInternal_003Eb__46);
					_003C_003Ec__DisplayClass18_22.CS_0024_003C_003E8__locals21.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_22._003CRegisterInternal_003Eb__47);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(uint[]))
				{
					_003C_003Ec__DisplayClass18_22<T> _003C_003Ec__DisplayClass18_23 = new _003C_003Ec__DisplayClass18_22<T>();
					_003C_003Ec__DisplayClass18_23.CS_0024_003C_003E8__locals22 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_23.setDelegate = ExtractSetDelegate<T, uint[]>(setMethod);
					_003C_003Ec__DisplayClass18_23.getDelegate = ExtractGetDelegate<T, uint[]>(getMethod);
					_003C_003Ec__DisplayClass18_23.CS_0024_003C_003E8__locals22.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_23._003CRegisterInternal_003Eb__48);
					_003C_003Ec__DisplayClass18_23.CS_0024_003C_003E8__locals22.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_23._003CRegisterInternal_003Eb__49);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(long[]))
				{
					_003C_003Ec__DisplayClass18_23<T> _003C_003Ec__DisplayClass18_24 = new _003C_003Ec__DisplayClass18_23<T>();
					_003C_003Ec__DisplayClass18_24.CS_0024_003C_003E8__locals23 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_24.setDelegate = ExtractSetDelegate<T, long[]>(setMethod);
					_003C_003Ec__DisplayClass18_24.getDelegate = ExtractGetDelegate<T, long[]>(getMethod);
					_003C_003Ec__DisplayClass18_24.CS_0024_003C_003E8__locals23.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_24._003CRegisterInternal_003Eb__50);
					_003C_003Ec__DisplayClass18_24.CS_0024_003C_003E8__locals23.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_24._003CRegisterInternal_003Eb__51);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(ulong[]))
				{
					_003C_003Ec__DisplayClass18_24<T> _003C_003Ec__DisplayClass18_25 = new _003C_003Ec__DisplayClass18_24<T>();
					_003C_003Ec__DisplayClass18_25.CS_0024_003C_003E8__locals24 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_25.setDelegate = ExtractSetDelegate<T, ulong[]>(setMethod);
					_003C_003Ec__DisplayClass18_25.getDelegate = ExtractGetDelegate<T, ulong[]>(getMethod);
					_003C_003Ec__DisplayClass18_25.CS_0024_003C_003E8__locals24.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_25._003CRegisterInternal_003Eb__52);
					_003C_003Ec__DisplayClass18_25.CS_0024_003C_003E8__locals24.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_25._003CRegisterInternal_003Eb__53);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(float[]))
				{
					_003C_003Ec__DisplayClass18_25<T> _003C_003Ec__DisplayClass18_26 = new _003C_003Ec__DisplayClass18_25<T>();
					_003C_003Ec__DisplayClass18_26.CS_0024_003C_003E8__locals25 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_26.setDelegate = ExtractSetDelegate<T, float[]>(setMethod);
					_003C_003Ec__DisplayClass18_26.getDelegate = ExtractGetDelegate<T, float[]>(getMethod);
					_003C_003Ec__DisplayClass18_26.CS_0024_003C_003E8__locals25.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_26._003CRegisterInternal_003Eb__54);
					_003C_003Ec__DisplayClass18_26.CS_0024_003C_003E8__locals25.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_26._003CRegisterInternal_003Eb__55);
					continue;
				}
				if (_003C_003Ec__DisplayClass18_2.propertyType == typeof(double[]))
				{
					_003C_003Ec__DisplayClass18_26<T> _003C_003Ec__DisplayClass18_27 = new _003C_003Ec__DisplayClass18_26<T>();
					_003C_003Ec__DisplayClass18_27.CS_0024_003C_003E8__locals26 = _003C_003Ec__DisplayClass18_2;
					_003C_003Ec__DisplayClass18_27.setDelegate = ExtractSetDelegate<T, double[]>(setMethod);
					_003C_003Ec__DisplayClass18_27.getDelegate = ExtractGetDelegate<T, double[]>(getMethod);
					_003C_003Ec__DisplayClass18_27.CS_0024_003C_003E8__locals26.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_27._003CRegisterInternal_003Eb__56);
					_003C_003Ec__DisplayClass18_27.CS_0024_003C_003E8__locals26.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_27._003CRegisterInternal_003Eb__57);
					continue;
				}
				_003C_003Ec__DisplayClass18_27<T> _003C_003Ec__DisplayClass18_28 = new _003C_003Ec__DisplayClass18_27<T>();
				_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27 = _003C_003Ec__DisplayClass18_2;
				bool flag = false;
				if (_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.propertyType.IsArray)
				{
					flag = true;
					_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.propertyType = _003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.propertyType.GetElementType();
				}
				if (_registeredNestedTypes.TryGetValue(_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.propertyType, out _003C_003Ec__DisplayClass18_28.registeredNestedType))
				{
					if (flag)
					{
						_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_28._003CRegisterInternal_003Eb__58);
						_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_28._003CRegisterInternal_003Eb__59);
					}
					else
					{
						_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.ReadDelegate[i] = new Action<NetDataReader>(_003C_003Ec__DisplayClass18_28._003CRegisterInternal_003Eb__60);
						_003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.CS_0024_003C_003E8__locals1.info.WriteDelegate[i] = new Action<NetDataWriter>(_003C_003Ec__DisplayClass18_28._003CRegisterInternal_003Eb__61);
					}
					continue;
				}
				throw new InvalidTypeException("Unknown property type: " + _003C_003Ec__DisplayClass18_28.CS_0024_003C_003E8__locals27.propertyType.FullName);
			}
			_registeredTypes.Add(fullName, _003C_003Ec__DisplayClass18_.info);
			return _003C_003Ec__DisplayClass18_.info;
		}

		public void Register<T>()
		{
			RegisterInternal<T>();
		}

		public T Deserialize<T>(NetDataReader reader) where T : class, new()
		{
			StructInfo structInfo = RegisterInternal<T>();
			structInfo.Reference = new T();
			try
			{
				structInfo.Read(reader);
			}
			catch
			{
				return null;
			}
			return (T)structInfo.Reference;
		}

		public bool Deserialize<T>(NetDataReader reader, T target) where T : class, new()
		{
			StructInfo structInfo = RegisterInternal<T>();
			structInfo.Reference = target;
			try
			{
				structInfo.Read(reader);
			}
			catch
			{
				return false;
			}
			return true;
		}

		public void Serialize<T>(NetDataWriter writer, T obj) where T : class, new()
		{
			RegisterInternal<T>().Write(writer, obj);
		}

		public byte[] Serialize<T>(T obj) where T : class, new()
		{
			_writer.Reset();
			Serialize(_writer, obj);
			return _writer.CopyData();
		}

		static NetSerializer()
		{
			HashSet<Type> hashSet = new HashSet<Type>();
			hashSet.Add(typeof(int));
			hashSet.Add(typeof(uint));
			hashSet.Add(typeof(byte));
			hashSet.Add(typeof(sbyte));
			hashSet.Add(typeof(short));
			hashSet.Add(typeof(ushort));
			hashSet.Add(typeof(long));
			hashSet.Add(typeof(ulong));
			hashSet.Add(typeof(string));
			hashSet.Add(typeof(float));
			hashSet.Add(typeof(double));
			hashSet.Add(typeof(bool));
			hashSet.Add(typeof(char));
			hashSet.Add(typeof(IPEndPoint));
			BasicTypes = hashSet;
		}
	}
}
